<!DOCTYPE html>
<!--管理员 实验室借用审批页面-->
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <title>实验室使用审批</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="static/css/layui.css" media="all">
  <link rel="stylesheet" href="static/layuiadmin/style/admin.css" media="all">
<!--  <script src="static/js/jquery-2.1.3.min.js"></script>-->
</head>
<body>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>信息管理</cite></a>
    <a><cite>实验室使用审批</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
      <div class="layui-card">
        <div class="layui-card-header card-title">实验室使用审批</div>
        <div class="layui-card-body">
          <table class="layui-hide" id="test-table-cellEdit" lay-filter="test-table-cellEdit"></table>
          <script type="text/html" id="test-table-operate-barDemo">
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="ty">同意</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="bty">不同意</a>
          </script>
        </div>
      </div>
    </div>
  </div>
</div>

<script src="static/layui.js"></script>
<script th:inline="none">
  layui.config({
    base: 'static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'table','form'], function(){
    var $ = layui.$;
    var table = layui.table;
    var form = layui.form;
    var exportData;
    var loading = layer.load();
    var ins1 = table.render({

      elem: '#test-table-cellEdit'
      ,method:'post'
      , url: '/selectsyssysp'
      , cols: [[
        {field: 'sysname', title: '实验室名称', width: 120, sort: true},
        {field: 'lx', title: '实验室类型', width: 120,  sort: true},
        {field: 'bh', title: '实验室编号', width: 120, sort: true},
        {field: 'lc', title: '所在楼层', width: 120, sort: true},
        {field: 'fzrid', title: '课程大纲', width: 120, sort: true,templet:function (d) {
            if (d.fzrid)
              return '<a href="' + d.fzrid + '" download="文档">下载</a>'
            else
              return '无附件'
          }},
        {field: 'yyr', title: '预约人', width: 120, sort: true}
        , {width: 178, align: 'center', fixed: 'right', toolbar: '#test-table-operate-barDemo'}
      ]]
      , done: function (res, curr, count) {
        layer.close(loading);
      }
    })

      //监听工具条
    table.on('tool(test-table-cellEdit)', function(obj){
      var data = obj.data;
      if(obj.event === 'ty'){
        layer.confirm('确定同意？', function(index){
          $.ajax({
            url:"/syssyspty",
            data:{id:data.id},
            type:"post",
            dataType:"json",
            success: function (result) {
              layer.msg('已同意',{icon:1});
              window.location.reload();
            },
            error:function (e) {
              layer.msg('服务器错误',{icon:2});
            }
          })
          layer.close(index);
        });
      }

      if(obj.event === 'bty'){
        layer.confirm('确认操作？', function(index){
          $.ajax({
            url:"/syssysptybty",
            data:{id:data.id},
            type:"post",
            dataType:"json",
            success: function (result) {
              layer.msg('已拒绝',{icon:1});
              window.location.reload();
            },
            error:function (e) {
              layer.msg('服务器错误',{icon:2});
            }
          })
          layer.close(index);
        });
      }
    });
  });

</script>
</body>
</html>